home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / person / factoria.zip / FACTORIA.PRG < prev    next >
Text File  |  1992-10-18  |  2KB  |  58 lines

  1. * ****************************************************************
  2. * Goofy program to calculate combinations.
  3. * Written by Rod Potter (email rodp@orion.yorku.ca)
  4. * and foisted on an unsuspecting public.
  5. ******************************************************************
  6.  
  7. CLEAR
  8. SET STATUS OFF
  9. SET SCOREBOARD OFF
  10. SET COLO TO /W
  11. @ 01,00 SAY SPACE(80)
  12. @ 01,23 SAY " If I had a million dollars... "
  13. SET COLO TO W/
  14.  
  15. DO WHILE .T.
  16.    STORE 0 TO NUM,UNIVERSE,NUM2DRAW,M_ANSWER
  17.    @ 08,08 CLEAR TO 15,72
  18.    @ 08,08 TO 15,72
  19.    @ 10,13 SAY "Size of pool to draw from (1-125) " GET UNIVERSE PICT "##########" RANGE 1,125
  20.    @ 11,13 SAY "            Size of group (1-125) " GET NUM2DRAW PICT "##########" RANGE 1,125
  21.    READ
  22.    DO CASE 
  23.       CASE NUM2DRAW = UNIVERSE
  24.            @ 13,13 SAY "Great odds! Only 1 combination!"
  25.       CASE NUM2DRAW > UNIVERSE
  26.            OK=" "
  27.            @ 23,00 TO 23,79
  28.            @ 24,00 SAY SPACE(80)
  29.            @ 24,00 SAY " Size of group must be smaller than the Pool... Try again." GET OK
  30.            READ
  31.            @ 23,00 CLEAR
  32.       CASE UNIVERSE=0 .or. NUM2DRAW=0
  33.            ** Try again **
  34.       OTHER
  35.            STORE FACT(UNIVERSE) / ( FACT(NUM2DRAW) * FACT(UNIVERSE-NUM2DRAW) ) TO M_ANSWER
  36.            @ 13,13 SAY "The Number of combinations is " + LTRIM(STR(INT(M_ANSWER)))
  37.    ENDCASE
  38.    OK=" "
  39.    @ 23,00 TO 23,79
  40.    @ 24,00 SAY SPACE(80)
  41.    @ 24,00 SAY " Try your luck again? (y/n) " GET OK
  42.    READ
  43.    @ 23,00 CLEAR
  44.    IF .not. OK$"yY"
  45.       CLEAR
  46.       EXIT
  47.    ENDIF
  48. ENDDO
  49.  
  50. FUNCTION FACT
  51. PARAMETER NUM
  52. STORE NUM TO ANSWER
  53. FOR NUM = NUM-1 TO 1 STEP - 1
  54.    ANSWER = ANSWER*NUM 
  55. NEXT
  56. RETURN ANSWER
  57.  
  58.